<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>使用JSON</title>
    <script>
      log("json对象 就是 JavaScript对象");
      log("JSON.stringify(any) json对象转json字符串");
      let data = { name: "dong", age: 12 };
      console.log(data);
      let dataStr = JSON.stringify(data);
      console.log(dataStr);

      log("JSON.parse(text) json字符串转json对象");
      let data1Str = '{"name":"dong","age":12}';
      console.log(data1Str);
      let data1 = JSON.parse(data1Str);
      console.log(data1);

      function log(msg) {
        console.log("---------------------", msg, "---------------------");
      }
    </script>
  </head>
  <body></body>
</html>
